package com.veetao.api.utils;

import java.util.Date;

import com.veetao.api.utils.DateUtil;

public class CacheUtils {

	public static String generateMobileValidCodeKey(String mobile) {
		return String.format("whenhi.mobile.validcode.%s", mobile);
	}

	public static String generateUserGrowLockKey(int userId) {
		return String.format("whenhi.user.growlock.%s", userId);
	}

	public static String generateFeedHomeKey(int pageNo, int userCategory) {
		return String.format("whenhi.feed.homelist.%s.%s", userCategory, pageNo);
	}

	public static String generateHomeDataKey() {
		return "whenhi.feed.homedata";
	}

	public static String generateUserInfoKey(int userId) {
		return String.format("whenhi.user.info.%s", userId);
	}

	public static String generateUserDynamicInfoKey(int userId) {
		return String.format("whenhi.user.dynamicinfo.%s", userId);
	}

	public static String generatePagedCommentListKey(int feedId, int pageNo) {
		return String.format("whenhi.feed.comment.%d.%d", feedId, pageNo);
	}

	public static String generateUserFeedListKey(int userId, int pageNo) {
		return String.format("whenhi.user.feeds.%d.%d", userId, pageNo);
	}

	public static String generateFeedWhoLikedKey(int feedId) {
		return String.format("whenhi.feed.likedusers.%d", feedId);
	}

	public static String generateUserAllLikedFeedsKey(int userId) {
		return String.format("whenhi.user.likedfeeds.%d", userId);
	}

	/**
	 * @param userId
	 * @return
	 * @author guohongtao
	 */
	public static String generateUserFavoriteFeedsKey(int userId) {
		return String.format("whenhi.user.favoritefeeds.%d", userId);
	}

	/**
	 * @return
	 * @author guohongtao
	 */
	public static String generateUserBlacklistKey() {
		return "whenhi.user.blacklist";
	}


	/**
	 * @param wxAppId
	 * @return
	 * @author guohongtao
	 */
	public static String generateWeixinTicketKey(String wxAppId) {
		return String.format("weixin.jsticket.%s", wxAppId);
	}

	/**
	 * @param wxAppId
	 * @return
	 * @author guohongtao
	 */
	public static String generateWeixinAccessLockKey(String wxAppId) {
		return String.format("weixin.ac.lock.%s", wxAppId);
	}

	/**
	 * @param userId
	 * @return
	 * @author guohongtao
	 */
	public static String generateUserCheckinKey(int userId, String dateStr) {
		return String.format("whenhi.user.checkin.%s.%s", userId, dateStr);
	}

	/**
	 * @param userCategory
	 * @return
	 * @author guohongtao
	 */
	public static String generateFeedHomeUserFeedListKey(int userCategory) {
		return String.format("whenhi.feedhome.userfeedlist.%d", userCategory);
	}

	/**
	 * @param pageNo
	 * @param userCategory
	 * @return
	 * @author guohongtao
	 */
	public static String generatePersonalizeFeedHomeKey(int pageNo,
			int userCategory) {
		return String.format("whenhi.feed.home1.%s.%s", userCategory, pageNo);
	}

	/**
	 * @param userId
	 * @param did
	 * @return
	 * @author guohongtao
	 */
	public static String generateUserFeedHomeIdsKey(int userId, String did) {
		return String.format("whenhi.homeids.%s.%s", userId, did);
	}

	/**
	 * @return
	 * @author guohongtao
	 */
	public static String generatePersonalizeHomeDataKey() {
		return "whenhi.feed.homedata.1";
	}

	/**
	 * @param userId
	 * @return
	 * @author guohongtao
	 */
	public static String generateUserFollowsKey(int userId) {
		return String.format("whenhi.user.follows.%s", userId);
	}
	public static String generateUserFollowersKey(int userId) {
		return String.format("whenhi.user.followers.%s", userId);
	}

	/**
	 * @param userId
	 * @return
	 * @author guohongtao
	 */
	public static String generateUserLocationKey(int userId) {
		
		return String.format("whenhi.user.location.%s", userId);
	}

	/**
	 * @param mobile
	 * @return
	 * @author guohongtao
	 */
	public static String generateNewMobileValidCodeKey(String mobile) {
		return String.format("whenhi.n_mobile.validcode.%s", mobile);
	}

	/**
	 * @param appId
	 * @param channel
	 * @return
	 * @author guohongtao
	 */
	public static String generateUpgradeVersionKey(int appId, String channel) {
		return String.format("whenhi.app.upgrade.%s.%s", appId,channel);
	}

	/**
	 * @param feedId
	 * @return
	 * @author guohongtao
	 */
	public static String generateUserFeedInfoKey(int feedId) {
		return String.format("whenhi.userfeed.%s", feedId);
	}

	/**
	 * @param followerId
	 * @return
	 * @author guohongtao
	 */
	public static String generateUserFollowFeedKey(int userId) {
		return String.format("whenhi.user.followfeed.%d", userId);
	}
	
	public static String generateUserFollowerFeedKey(int userId) {
		return String.format("whenhi.user.followerfeed.%d", userId);
	}

	/**
	 * @param userId
	 * @return
	 * @author guohongtao
	 */
	public static String generateUserCommonFoodKey(int userId) {
		return String.format("whenhi.user.commonfood.%d", userId);
	}

	/**
	 * @param deviceId
	 * @return
	 * @author guohongtao
	 */
	public static String generateDeviceInfoCachaKey(String deviceId) {
		return String.format("whenhi.deviceinfo.%s", deviceId);
	}

	public static String generateTopScoreUserListKey() {
		return "whenhi.topscore.user.list";
	}

	public static String generateTypedValidCodeKey(String type, String mobile) {
		return String.format("whenhi.validcode.%s,%s", mobile, type);
	}

	public static String generateUserTodayAwardScoreKey(int userId) {
		String today = DateUtil.dateToStr(new Date(), "yyyyMMdd");
		return String.format("whenhi.user.awards.%s.%s", today, userId);
	}

	public static String generateUserFeedListExtrasKey(int userId,int feedCategory) {
		return String.format("whenhi.user.feedlist.extras.%s.%s", userId, feedCategory);
	}

	public static String generateWeixinBindTokenKey(String token) {
		return String.format("whenhi.bind.token.", token);
	}

}
